<template>
  <div class="container">
    <img src="http://ciy.oss-cn-shenzhen.aliyuncs.com/web/cut/cut-bak2.jpg" class="launchCut_background" />
    <input type="text" class="launchCut_schoolInput launchCut_input" placeholder="请输入你学校的名字" v-model="school"/>
    <input type="text" class="launchCut_classInput launchCut_input" placeholder="请输入定制数量"v-model="classNumber"/>
    <!-- <div class="launchCut_btn" @click="cut">
      <img src="http://ciy.oss-cn-shenzhen.aliyuncs.com/web/cut/cut-btn.png"/>
    </div> -->
    <form @submit="cut($event)" :report-submit="true" class="launchCut_btn">
      <button formType="submit" hover-class="none"  class='submit_kong_btn'>
          <img src="http://ciy.oss-cn-shenzhen.aliyuncs.com/web/cut/cut-btn3.png"/>
      </button>
    </form>
 <!--    <div class="launchCut_btn" @click="cut">
      <img src="http://ciy.oss-cn-shenzhen.aliyuncs.com/web/cut/cut-btn.png"/>
    </div> -->
     <div class="ucenter">
          <navigator url="../personal/main">
            <img src="http://ciy.oss-cn-shenzhen.aliyuncs.com/web/cut/icon-ucenter.png" class="customer"/>
          </navigator>
    </div>
    <div class="customerWrap">
          <navigator url="../customer/main">
            <img src="http://file.rzkeji.com/web/loveciy/img/customer.png" class="customer"/>
          </navigator>
    </div>
  </div>
</template>

<script>

export default {
  data () {
    return {
      classNumber:"",
      school:""
    }
  },
  methods:{
    async cut(e){
      var formId = e.mp.detail.formId;
      let userToken=wx.getStorageSync('userToken')
      let res=await this.$request.postData('https://diy.zoomyoung.cn/api/activity/buildActivityBargain',{user_token:userToken,school_name:this.school,num:this.classNumber,form_id:formId});
      wx.navigateTo({
        url:'../cutPrice/main?id='+res.data.data.id
      })
    },
    checkHasJoin(){
      var _this=this;
      let userToken=wx.getStorageSync('userToken');
      _this.$request.getData('https://diy.zoomyoung.cn/api/activity/getUserActiveBargain?user_token='+userToken,"").then(res =>{
          if(res.data.level == "success" && res.data.data != null){
              wx.showModal({
                  title:"提示",
                  content:"您已存在正在进行中的砍价活动，是否前往查看？",
                  showCancel: true,
                  cancelText:"重新创建",
                  cancelColor:'#000000',
                  confirmText:"前往查看",
                  confirmColor: '#3cc51f',
                  success: function (reback) {
                      if (reback.cancel) {
                      } else {
                          wx.redirectTo({
                              url:'../cutPrice/main?id='+res.data.data.id
                          })
                      }
                  }
              })
          }
      })
    }
  },
    onShow(){
      this.checkHasJoin()
    },
    onShareAppMessage: function (res) {   //分享
        this.$currency.share(res,'班服定制/砍价活动','/pages/launchCut/main')
    }
}
</script>

<style scoped>
.container{width: 100%;height: 100%;position: relative;overflow: hidden;}
.launchCut_background{width: 100%;height: 100%;display: block;position: absolute;left: 0;top: 0}
.launchCut_input{width:176.5px;height: 32px;border-radius: 15px; position: absolute;left: 50%;margin-left: -95.75px;border:1px solid #797979;background-color: #fff;line-height: 32px;padding-left: 15px;font-size: 12px;}
.launchCut_schoolInput{top: 285px;}
.launchCut_classInput{top: 325px;}
.launchCut_btn{width: 128px;height:31px;position: absolute;left: 50%;top: 370px;margin-left: -62px; }
.launchCut_btn img{width: 100%;height: 100%;}
.customerWrap{width: 50px;height: 50px;position: fixed;right: 20px;bottom: 120px;background: rgba(0,0,0,0.5);border-radius: 50px;}
.customer{width:40px;height:40px;margin-left:5px;margin-top:5px;}
.ucenter{width: 50px;height: 50px;position: fixed;right: 20px;bottom: 179px;background: rgba(0,0,0,0.5);border-radius: 50px;}
.submit_kong_btn{width:100%;height:100%;left:0;top:0;border:none;background:none;}
.submit_kong_btn::after{ border: none; }
</style>
